<? 
	include('base.php');
	User::protect();
	include_class('releases');
	include_class('m2');
	include_class('release_tracks');
	$r = Release::get($_GET['id']);
	$section='releases';
	if ($_POST['submit'] && !db::isError($r)) { 
		// add news entry
		$rt = $r->addTrack($_POST);
		if (!db::isError($rt)) {
			header('Location: release_track_edit.php?id=' . $rt->getID());
		}
	}	
	$editors = array('lyrics','meta_information');
	$page_title = 'Add Track';
	include('layout/header.php');

if (!db::isError($r)) { ?>

<div id="breadcrumb">
	<a href="index.php">Audition &#62;</a>
	<a href="releases.php">Releases &#62;</a>
	<a href="release_edit.php?id=<?=$_GET['id']?>">View/Edit Release &#62;</a>
	Add Track
</div>

		<? if (User::isAdmin()) { 
		
			if (db::isError($rt)) {
				$rt->outputList();
			}
		
		?>
		
		<h1>add new entry:</h1>
		<div class="inset">
		<form id="add_new_entry" action="<?=$PHP_SELF?>?id=<?=$_GET['id']?>" method="post">
		<table border="0" class="edit-form" cellspacing="0" cellpadding="0">
		<tr>
			<td width="25%"><strong>Track #</strong><br/>
			<input type="text" name="number" value="<?=$_POST['number']?>" class="text"></td>
			<td width="25%"><strong>Length (m:s)</strong><br/>
			<input type="text" name="length" value="<?=$_POST['length']?>" class="text"></td>
			<td width="50%"><strong>Title</strong><br/>
			<input type="text" name="title" value="<?=$_POST['title']?>" class="text"></td>
		</tr>
		</table>
		<div class="edit-form">
			<strong>Lyrics:</strong><br/>
			<textarea name="lyrics" class="full" id="lyrics"><?=$_POST['lyrics']?></textarea>
		</div>
		<div class="edit-form">
			<strong>Meta Information</strong><br/>
			<textarea name="meta_information" class="full" id="meta_information"><?=$_POST['meta_information']?></textarea>
		</div>
		<div class="edit-form">
			<input type="submit" value="Add Track" class="button" name="submit" class="button">
			<input type="submit" value="Exit Without Updating" class="button" name="preview" onclick="location.href='release_edit.php?id=<?= $_GET['id'] ?>'; return false" class="button">
		</div>
		</div>
		
		<? } else {
		
			Error::outputDialog('Return to Release', 'release_edit.php?id=' . $_GET['id'], 'You do not have permission to add tracks.');
			
		}

	} else { ?>


<div id="breadcrumb">
	<a href="index.php">Audition &#62;</a>
	<a href="releases.php">Releases &#62;</a>
	Invalid Entry
</div>

		
<?

$r->outputDialog('Return to Releases','releases.php');

}


include('layout/footer.php'); ?>
